<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>大河网订阅管理系统</title>
    <style>

      body {
          margin: 0;
          padding: 0;
      }

      .right {
        color: green;
        font-weight: 700;
      }

      .error {
        color: red;
        font-weight: 700;
      }
    </style>
    <link href="css/css.css" rel="stylesheet" type="text/css" />
    <script src="js/jQuery-3.7.1.js"></script>
  </head>

  <body>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="147" background="images/top02.gif"><img style="float: left;" src="images/top03.gif" width="776" height="147" /></td>
      </tr>
    </table>
    <table width="1000" border="0" align="center" cellpadding="0" cellspacing="0" class="right-table03">
      <tr>
        <td width="221">
          <table width="95%" border="0" cellpadding="0" cellspacing="0" class="login-text01">

            <tr>
              <td>
                <table width="100%" border="0" cellpadding="0" cellspacing="0" class="login-text01">
                  <tr>
                    <td align="center"><img src="images/ico13.gif" width="107" height="97" /></td>
                  </tr>
                  <tr>
                    <td height="40" align="center">&nbsp;</td>
                  </tr>
                </table>
              </td>
              <td><img src="images/line01.gif" width="5" height="292" /></td>
            </tr>
          </table>
        </td>
        <td>
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="18%" height="35" class="login-text02">用户名称：<br /></td>
              <td width="69%"><input name="user" type="text" size="30" id="user"/><span id="msg"></span></td>
            </tr>
            <tr>
              <td height="35" class="login-text02">密　码：<br /></td>
              <td><input name="pass" type="password" size="30" id="pass"/></td>
            </tr>
            <tr>
              <td height="35"></td>
              <td><input name="submit2" type="button" id="btn-login" class="right-button01" value="确认登录" />
                <input name="submit232" type="reset" class="right-button02" value="重 置" /></td>
            </tr>
          </table>
        </td>
      </tr>
    </table>
    <script>
      // 1.页面加载完成,账户获取焦点
      window.onload = function () {
        $("#user").focus()
      }

      // 2.登录按钮绑定点击事件
      $("#btn-login").click(function () {
        // 1.获取请求参数
        let sendData = {"method": "login","user": $("#user").val(),"pass": $("#pass").val()};
        // 2.发送请求
        $.getJSON("admin",sendData,function (result) {
          // 1.判断返回结果是否正常
          if (result.code == 200){
            alert("登录成功!")
            // 跳转主程序页面
            window.location.href = "main.html"
          }else {
            // 登录失败
            alert("登录失败,请检查后重新登录!")
          }
        })
      })
    </script>
  </body>
</html>